var path = require('path');
var webpack = require('webpack');
const proxyConfig = require('./proxy.config');

var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(__dirname, './src/entry/index.jsx');
var BUILD_PATH = path.resolve(__dirname, './build');
var ExtractTextPlugin = require("extract-text-webpack-plugin");//提取css

module.exports = {
	entry: {
    app: [
			'webpack/hot/dev-server',
			'webpack-dev-server/client?http://localhost:8080',
	  	APP_PATH
		],
    vendor: ["react","react-dom","react-router"],
  },
	devServer: {
    contentBase: './build/', // Relative directory for base of server
    devtool: 'eval',
    inline: true,
		noInfo: false,
    proxy: proxyConfig
  },
	output: {
		path: BUILD_PATH,
		filename: "app.js",
		chunkFilename: "[id].bundle.js",
		// publicPath: "/index.html"
	},
	module: {
		loaders: [{
			test: /\.jsx?$/,
			loaders: ['babel-loader?presets[]=es2015,presets[]=react']
		},
		// {
		// 	test: /\.less$/,
		// 	loader: 'style!css!less'
		// },
		{
      test: /\.less$/,
      loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
    },
		{
    		test: /\.(png|jpg)$/,
    		loader: 'url?limit=50000'
    	}]
	},
	resolve: {// 现在你require文件的时候可以直接使用require('file')，不用使用require('file.coffee')
    extensions: ['', '.js','.jsx', '.json', '.css','.less']
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
		new ExtractTextPlugin("bundle.css"),
		new webpack.optimize.CommonsChunkPlugin("vendor","vendor.bundle.js")
  ],
}
